/*
origin glsl source: 
#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 0
#define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0
#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 4096
#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 1024
#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0
#define CC_PLATFORM_ANDROID_AND_WEBGL 0
#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0
#define CC_JOINT_UNIFORM_CAPACITY 256
#define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 6
#define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 1

precision mediump float;
varying vec2 v_uv;
  uniform float u_percent;
uniform sampler2D mainTexture;
vec4 frag () {
  vec4 color = texture2D(mainTexture, v_uv);
  float percent = clamp(u_percent, 0.0, 1.0);
  color.xyz *= percent;
  return color;
}
void main() { gl_FragColor = frag(); }
*/
export let glsl_1c6dd765e875d75103ff92995d103cb2 = `#define CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS 1
#define CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS 6
#define CC_JOINT_UNIFORM_CAPACITY 256
#define CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES 0
#define CC_PLATFORM_ANDROID_AND_WEBGL 0
#define CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT 0
#define CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS 1024
#define CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS 4096
#define CC_ENABLE_CLUSTERED_LIGHT_CULLING 0
#define CC_DEVICE_SUPPORT_FLOAT_TEXTURE 0

precision mediump float;
varying vec2 v_uv;
  uniform float u_percent;
uniform sampler2D mainTexture;
vec4 frag () {
  vec4 color = texture2D(mainTexture, v_uv);
  float percent = clamp(u_percent, 0.0, 1.0);
  color.xyz *= percent;
  return color;
}
void main() { gl_FragColor = frag(); }
`
import {
    texture2D_N_V2,
    clamp_N_N_N,
    sampler2D,
    samplerCube,
    float,
    float_N,
    bool,
    bool_N,
    int_N,
    int,
    vec4,
    vec3,
    vec2,
    mat2,
    mat3,
    mat4,
} from "../builtin/BuiltinFunc"
import { glSet_V2_V2, glSet_V4_V4, glSet_N_N, glMulSet_V3_N, getValueKeyByIndex, getOutValueKeyByIndex } from "../builtin/BuiltinOperator"
import {
    gl_FragData,
    gl_FragColor,
    gl_Position,
    gl_PointSize,
    gl_FragCoord,
    gl_FragDepth,
    gl_FrontFacing,
    custom_isDiscard,
} from "../builtin/BuiltinVar"
import { cpuRenderingContext } from "../../CpuRenderingContext"
import {
    AttributeData,
    FragShaderHandle,
    UniformData,
    VaryingData,
    ShaderLocalData,
    VertShaderHandle,
    StructData,
} from "../../ShaderDefine"
import {
    IntData,
    FloatData,
    Vec2Data,
    Vec3Data,
    Vec4Data,
    Mat2Data,
    Mat3Data,
    Mat4Data,
    BoolData,
    Sampler2D,
    SamplerCube,
} from "../builtin/BuiltinData"
let CC_DEVICE_SUPPORT_FLOAT_TEXTURE = new FloatData(0)
let CC_ENABLE_CLUSTERED_LIGHT_CULLING = new FloatData(0)
let CC_DEVICE_MAX_VERTEX_UNIFORM_VECTORS = new FloatData(4096)
let CC_DEVICE_MAX_FRAGMENT_UNIFORM_VECTORS = new FloatData(1024)
let CC_DEVICE_CAN_BENEFIT_FROM_INPUT_ATTACHMENT = new FloatData(0)
let CC_PLATFORM_ANDROID_AND_WEBGL = new FloatData(0)
let CC_ENABLE_WEBGL_HIGHP_STRUCT_VALUES = new FloatData(0)
let CC_JOINT_UNIFORM_CAPACITY = new FloatData(256)
let CC_EFFECT_USED_VERTEX_UNIFORM_VECTORS = new FloatData(6)
let CC_EFFECT_USED_FRAGMENT_UNIFORM_VECTORS = new FloatData(1)
class AttributeDataImpl implements AttributeData {
    dataKeys: Map<string, any> = new Map([])
    dataSize: Map<string, number> = new Map([])
}
class VaryingDataImpl extends VaryingData {
    v_uv: Vec2Data = new Vec2Data()

    factoryCreate() {
        return new VaryingDataImpl()
    }
    dataKeys: Map<string, any> = new Map([["v_uv", cpuRenderingContext.cachGameGl.FLOAT_VEC2]])
    copy(varying: VaryingDataImpl) {
        glSet_V2_V2(varying.v_uv, this.v_uv)
    }
}
class UniformDataImpl implements UniformData {
    u_percent: FloatData = new FloatData()
    mainTexture: Sampler2D = new Sampler2D()
    dataKeys: Map<string, any> = new Map([
        ["u_percent", cpuRenderingContext.cachGameGl.FLOAT],
        ["mainTexture", cpuRenderingContext.cachGameGl.SAMPLER_2D],
    ])
    dataSize: Map<string, number> = new Map([
        ["u_percent", 1],
        ["mainTexture", 1],
    ])
}
class ShaderLocalDataImpl implements ShaderLocalData {
    dataKeys: Map<string, any> = new Map([])
    dataSize: Map<string, number> = new Map([])
    init() {}
}
export class Impl_1c6dd765e875d75103ff92995d103cb2 extends FragShaderHandle {
    varyingData: VaryingDataImpl = new VaryingDataImpl()
    uniformData: UniformDataImpl = new UniformDataImpl()

    frag(): Vec4Data {
        let color: Vec4Data = vec4()
        glSet_V4_V4(color, texture2D_N_V2(this.uniformData.mainTexture, this.varyingData.v_uv))
        let percent: FloatData = float()
        glSet_N_N(percent, clamp_N_N_N(this.uniformData.u_percent, float_N(0.0), float_N(1.0)))
        glMulSet_V3_N(color.out_xyz, percent)
        return color
    }
    main(): void {
        glSet_V4_V4(gl_FragColor, this.frag())
    }
}
